package com.cms.controller.system;

import com.cms.controller.BaseController;
import com.cms.model.bo.ExcelExport;
import com.cms.model.vo.SysLog;
import com.cms.service.SysLogService;
import com.cms.utils.tools.CommonHelper;
import com.cms.utils.tools.DateUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.Date;


@Controller
@RequestMapping("syslog")
public class SysLogController extends BaseController {


    @Autowired
    private SysLogService sysLogService;

    /**
     *跳转到日志管理页面
     * @return
     */
    @RequestMapping("/sys_log_list.do")
    public String toSysLogPage(Model model) {
        String currentDate = DateUtil.Date2Stirng(new Date());
        model.addAttribute("currentDate",currentDate);
        return "system/log_list";
    }
    
    /**
     * 日志信息列表List
     * @param systemLog 日志实体
     * @return
     */
    @RequestMapping("/ajax_sys_log_list.do")
    @ResponseBody
    public String ajaxSysLogList(SysLog sysLog){
        return sysLogService.selectSystemLogResultPageList(sysLog);
    }

    /**
     * 日志导出
     * @param sysLog 日志实体
     * @return
     */
    @RequestMapping("/excel_sys_log_export.do")
    public ModelAndView excelSysLogExport(SysLog sysLog){
        ExcelExport excelExport = sysLogService.excelExportSystemLogList(sysLog);
        return CommonHelper.getExcelModelAndView(excelExport);
    }
}
